import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.KeyStroke;


public class BarMenu extends JMenuBar {
	String[ ] fileItems = new String[ ] { "New", "Open", "Save","Exit" };
	String[ ] editItems = new String[ ] { "Undo", "Cut", "Copy", "Paste" };
	
	
public BarMenu(){
	  JMenu fileMenu = new JMenu("File");
      JMenu editMenu = new JMenu("Edit");
      JMenu otherMenu = new JMenu("Other");
      JMenu subMenu = new JMenu("SubMenu");
      JMenu subMenu2 = new JMenu("SubMenu2");
      
      
      ActionListener printListener = new ActionListener(  ) {
         public void actionPerformed(ActionEvent event) {
        	 
        	 if(event.getActionCommand() == "New"){
        		 NewClassEditFrame class1 = new NewClassEditFrame(1);
        	 }
        	 
            System.out.println("Menu item [" + event.getActionCommand(  ) +
                               "] was pressed.");
         }
      };
      
      for (int i=0; i < fileItems.length; i++) {
         JMenuItem item = new JMenuItem(fileItems[i]);
         item.addActionListener(printListener);
         fileMenu.add(item);
      }

      
      for (int i=0; i < editItems.length; i++) {
         JMenuItem item = new JMenuItem(editItems[i]);
         item.addActionListener(printListener);
         editMenu.add(item);
      }

      
      //editMenu.insertSeparator(1);

      
      JMenuItem item;
      subMenu2.add(item = new JMenuItem("Extra 2"));
      item.addActionListener(printListener);
      subMenu.add(item = new JMenuItem("Extra 1"));
      item.addActionListener(printListener);
      subMenu.add(subMenu2);

      
      
      otherMenu.add(subMenu);
      otherMenu.add(item = new JCheckBoxMenuItem("Check Me"));
      item.addActionListener(printListener);
      otherMenu.addSeparator(  );
      ButtonGroup buttonGroup = new ButtonGroup(  );
      otherMenu.add(item = new JRadioButtonMenuItem("Radio 1"));
      item.addActionListener(printListener);
      buttonGroup.add(item);
      otherMenu.add(item = new JRadioButtonMenuItem("Radio 2"));
      item.addActionListener(printListener);
      buttonGroup.add(item);
      otherMenu.addSeparator(  );
      otherMenu.add(item = new JMenuItem("Potted Plant", new ImageIcon("image.gif")));
      item.addActionListener(printListener);

      
      
      add(fileMenu);
      add(editMenu);
      add(otherMenu);
   }


/*
   public static void main(String s[ ]) {
      JFrame frame = new JFrame("Simple Menu Example");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setJMenuBar(new BarMenu(  ));
      frame.pack(  );
      frame.setVisible(true);
   }
   */
   
}



